<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////
////  email = "wenpin.qian@happyelements.com"                     ////
////  team = "Athene"                                             ////
////  warnings = "This is generated page,Do Not Modify!";         ////
////  tips = "Opera & IE not supported|Chrome & Safari sugguested"////
//////////////////////////////////////////////////////////////////////
var DicItemEntitystr = window.dialogArguments;
var DicItemEntity = null;
if(DicItemEntitystr != undefined && DicItemEntitystr != "" && DicItemEntitystr != "{}") {
		DicItemEntity = s2json(DicItemEntitystr);
}
$(document).ready(function() {
	if(DicItemEntity != undefined) {
	
	$('#itemId').val(DicItemEntity.itemId);	
	$('#count').val(DicItemEntity.count);		
	}
	listselectors();
});
window.returnValue = DicItemEntitystr;

function listselectors() {
var getItemSelectorUrl = "/special/Item/getList/";
$.ajax({
		   type: "GET",
		   url: getItemSelectorUrl,
		   data: "",
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   selectitemId(s2json(data.result));
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

function submitDicItemEntity() {
	window.returnValue = json2s({
			
			itemId:$('#itemId').val(),			
			count:xparseInt($('#count').val()),						
	});
	beforeWindowClose();
	window.close();
}
function selectitemId(options) {
	var optionHTML = "";
	for(var i in options) {
		optionHTML = optionHTML + "<option value='"+ options[i][0] +"'>" + options[i][1] + "</option>\n";
	}
	$("#itemId").html(optionHTML);
	if(DicItemEntity != undefined) {
		$("#itemId").val(DicItemEntity.itemId);
	}
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}

</script>
<body onunload="beforeWindowClose()">
	<div class="addarea">
	<table>
		<tbody>			
				<tr>				<td>
					<label for="itemId">道具ID</label>
											<select id="itemId" name="itemId">
						</select>
									</td>
							
								<td>
					<label for="count">道具数量</label>
					
						<input type="text" id="count" name="count" />
									</td>
				</tr>					</tbody>
	</table>
	</div>
	<input type="button" onclick="submitDicItemEntity()" value="提交"/>
</body>